# -*- coding: utf-8 -*-
# @Time : 2021/9/4 9:21
# @Author : 唐宁
# @Site : 统一返回封装类
# @File : Result.py
# @Software: PyCharm
from exception.ErrorCodeEnum import ErrorCodeEnum


class Result:
    def __init__(self, data='', code=200, msg='请求通过'):
        self.code = code
        self.data = data
        self.msg = msg

    def error(self, error: ErrorCodeEnum, msg=None):
        self.code = error.code
        if msg:
            self.msg = msg
        else:
            self.msg = error.msg
        return self

    def success(self, data='', code=200, msg='请求通过'):
        self.data = data
        self.code = code
        self.msg = msg
        return self
